package com.ruoyi.file.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.file.domain.FileDO;
import com.ruoyi.file.domain.FileNoticeImagesDO;
import com.ruoyi.file.domain.vo.file.FileRespVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * 文件操作 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FileMapper extends BaseMapper<FileDO> {

//    default PageResult<FileDO> selectPage(FilePageReqVO reqVO) {
//        return selectPage(reqVO, new LambdaQueryWrapperX<FileDO>()
//                .likeIfPresent(FileDO::getPath, reqVO.getPath())
//                .likeIfPresent(FileDO::getType, reqVO.getType())
//                .betweenIfPresent(FileDO::getCreateTime, reqVO.getCreateTime())
//                .orderByDesc(FileDO::getId));
//    }
    void insertFile(FileDO fileDO);

    /**
     * 根据公告ID查询图片列表
     *
     * @param noticeId 公告ID
     * @return 图片列表
     */
    List<FileDO> selectNoticeImages(@Param("noticeId") Long noticeId);

    void deleteByNoticeIdAndFileIds(@Param("noticeId") Long noticeId, @Param("fileIds") Set<Long> fileIds);

    void insertBatch(@Param("fileNoticeImagesList") List<FileNoticeImagesDO> fileNoticeImagesList);

    @Select("SELECT * FROM file_notice_images WHERE notice_id = #{noticeId}")
    List<FileNoticeImagesDO> selectByNoticeId(@Param("noticeId") Long noticeId);

    void deleteByNoticeId(Long noticeId);
}
